﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Business;
using System.Threading;
public partial class client_Pswservice : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        btnSubmit.Attributes.Add("onclick", "return validate()");
        Response.Write("<script   language= 'javascript '> alert( 'incorrect old password！ ');</script> ");

    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        UserServices us = new UserServices();
        string username = Session["username"].ToString();
        bool result = us.updatepsw(username,TextBox_old.Text,TextBox_new.Text);
        if (result == false)
        {
            Response.Write("<script language='javascript'>alert('Incorrect old password')</script>");
                   }
        else
        {
            Response.Write("<script language='javascript'>alert('Successfully changed password')</script>");
           
            Server.Transfer("Main.aspx");
            //Response.Redirect("Main.aspx");
            //Response.Write("<script language='javascript'>history.back();</script> ");
        }
    }
}
